package com.sk.bilibili.config;

import android.app.Application;
import android.content.Context;
import android.content.SharedPreferences;

import com.sk.api.annotations.Bean;
import com.sk.bilibili.R;
import com.sk.bilibili.other.BiliBiliProperty;
import com.sk.bilibili.other.DownloadManager;
import com.sk.bilibili.other.VideoDao;
import com.sk.bilibili.utils.DensityUtils;
import com.sk.bilibili.utils.PreferenceUtils;

import java.io.InputStream;

public class OtherConfig {

    @Bean("property")
    public BiliBiliProperty config(Application application){
        InputStream is = application.getResources().openRawResource(R.raw.config);
        return new BiliBiliProperty(is);
    }

    @Bean
    public PreferenceUtils preferenceUtils(Application application, BiliBiliProperty property){
        SharedPreferences preferences = application.getSharedPreferences(
                property.getString("preferenceName"), Context.MODE_PRIVATE);
        return new PreferenceUtils(preferences);
    }

    @Bean
    public DensityUtils densityUtils(Application application){
        return new DensityUtils(application);
    }

    @Bean
    public VideoDao videoDao(Application application){
        return new VideoDao(application);
    }

    @Bean
    public DownloadManager downloadManager(Application application){
        return new DownloadManager(application);
    }

}